@page
@model ITAM.Pages.Assets.ImportDeviceModel
@{
    ViewData["Title"] = "设备导入";
}

<div class="row pr-3 pt-3 pl-3">
    <h5>设备导入</h5>
    <small class="pt-2px pl-1">主数据列表</small>
</div>
<div class="row pr-3 pl-3">
    <div class="col-md-4">
        <form method="POST">
            <fieldset>
                <div class="form-group">
                    <label asp-for="@Model.ExcelFile" class="form-label mt-4">选择导入的Excel表格</label>
                    <input  asp-for="@Model.ExcelFile" id="excelFile" class="file" type="file">
                </div>
                <button type="submit" class="btn btn-primary mt-3" asp-page-handler="UploadDevice">上传</button>
                <button type="submit" class="btn btn-primary mt-3" asp-page-handler="ImportDevice">导入</button>
            </fieldset>
        </form>
    </div>
    <div class="col-md-12 mt-4">
        <table class="table table-hover">
            <thead>
                <tr>
                    <th scope="col">资产编码</th>
                    <th scope="col">设备类型</th>
                    <th scope="col">设备ID</th>
                    <th scope="col">设备状态</th>
                    <th scope="col">IP</th>
                    <th scope="col">MAC</th>
                    <th scope="col">购买日期</th>
                    <th scope="col">过保日期</th>
                </tr>
            </thead>
            <tbody>
                @if (Model.Devices != null)
                {
                    foreach (var item in Model.Devices)
                    {
                        <tr class="table-primary">
                            <th scope="row">@item.AssetNumber</th>
                            <td>@item.CategoryName</td>
                            <td>@item.Id</td>
                            <td>@item.State</td>
                            <td>@item.Ip</td>
                            <td>@item.Mac</td>
                            <td>
                                @(item.PurchasedDate==null?"":((DateTime)item.PurchasedDate).ToString("yyyy-MM-dd"))
                            </td>
                            <td>
                                @(item.ExpireDate==null?"":((DateTime)item.ExpireDate).ToString("yyyy-MM-dd"))
                            </td>
                        </tr>
                    }
                }
            </tbody>
        </table>
    </div>
</div>

@section FileInputCss {
<link rel="stylesheet" href="~/lib/bootstrap-icons/bootstrap-icons.min.css" />
<link rel="stylesheet" href="~/lib/bootstrap-fileinput/css/fileinput.min.css" />
<link rel="stylesheet" href="~/lib/all.css" />
<link rel="stylesheet" href="~/lib/bootstrap-fileinput/themes/explorer-fas/theme.css" />
}

@section FileInputJs {
<script src="~/lib/bootstrap-fileinput/js/plugins/piexif.min.js"></script>
<script src="~/lib/bootstrap-fileinput/js/plugins/sortable.min.js"></script>
}

@section Scripts {
<script src="~/lib/bootstrap-fileinput/js/fileinput.min.js"></script>
<script src="~/lib/bootstrap-fileinput/js/locales/LANG.js"></script>
}